﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace game
{
    static class Text2D
    {
        private static SpriteBatch spriteBatch;
        public static SpriteFont SpriteFont;

        public static void Initialize(Game game)
        {
            spriteBatch = new SpriteBatch(game.GraphicsDevice);
            SpriteFont = game.Content.Load<SpriteFont>("Fonts\\Arial");
        }

        public static void Draw(string text)                         // Basic DrawText function taking a string as argument
        {
            spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Deferred, SaveStateMode.SaveState);
            spriteBatch.DrawString(SpriteFont, text, new Vector2(0.0f, 0.0f), Color.DarkBlue);
            spriteBatch.End();
        }

        public static void Draw(string text, Vector2 fontPos)       // Overloaded DrawText function taking a string and position coordinates as a Vector2 variable
        {
            spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Deferred, SaveStateMode.SaveState);
            spriteBatch.DrawString(SpriteFont, text, fontPos, Color.DarkBlue);
            spriteBatch.End();
        }

        public static void Draw(string text, Vector2 fontPos, Color color)       // Overloaded DrawText function taking a string and position coordinates as a Vector2 variable and font color
        {
            spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Deferred, SaveStateMode.SaveState);
            spriteBatch.DrawString(SpriteFont, text, fontPos, color);
            spriteBatch.End();
        }

        public static void Draw(string text, Vector2 fontPos, Color color, Vector2 scale)       // Overloaded DrawText function taking a string and position coordinates as a Vector2 variable, font color and font scale.
        {
            spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Deferred, SaveStateMode.SaveState);
            spriteBatch.DrawString(SpriteFont, text, fontPos, color, 0, new Vector2(0.0f, 0.0f), scale, SpriteEffects.None, 0);
            spriteBatch.End();
        }
        
        // More fancy overloads comming soon :)
    }
}
